import { ServicesModule } from '@app/services';
import { ApolloDriver, ApolloDriverConfig } from '@nestjs/apollo';
import { Module } from '@nestjs/common';
import { GraphQLModule } from '@nestjs/graphql';
import { GraphQLDate, GraphQLObjectID } from 'graphql-scalars';
import { join } from 'path';

const scalarsMap = {
  Date: GraphQLDate,
  ObjectID: GraphQLObjectID,
};
@Module({
  imports: [
    GraphQLModule.forRoot<ApolloDriverConfig>({
      driver: ApolloDriver,
      typePaths: [join(process.cwd(), './libs/**/*.graphql')],
      resolvers: scalarsMap,
      definitions: {
        path: join(
          process.cwd(),
          './libs/common/src/types/graphqls/graphql.schema.ts',
        ),
        outputAs: 'class',
      },
      playground: true,
    }),
    // DatabaseModule,
    ServicesModule,
  ],
  exports: [],
})
export class GraphqlModule {}
